import com.sun.org.apache.xpath.internal.operations.Neg;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/*
FileReader是一个字符输入流在读取文本的时候比较方便快捷。
 */
public class FileReaderTest01 {
    public static void main(String[] args) {
    FileReader reader = null;
        try {
            reader = new FileReader("C:\\Users\\30539\\Desktop\\text.txt");
            char[] chars = new char[5];
            int readercount =0;
            while((readercount=reader.read(chars))!=-1) {
                System.out.println(new String(chars,0,readercount));
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if(reader!=null){
                try {
                    reader.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
